From dcd37b824c1bc519ed290fc112db3baa8c441621 Mon Sep 17 00:00:00 2001 From: "tsteven4@gmail.com" Date: Thu, 12 Sep 2013 02:52:40 +0000 Subject: [PATCH] Get the gui ready for Qt5 while maintaining support for Qt4. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4605 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/gui/app.pro | 9 +++++++-- gpsbabel/gui/main.cc | 10 ++++++++++ gpsbabel/gui/makelinuxdist.sh.in | 14 +++++++++++++- gpsbabel/gui/optionsdlg.cc | 2 +- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/gpsbabel/gui/app.pro b/gpsbabel/gui/app.pro index bd14d2030..3e933875d 100755 --- a/gpsbabel/gui/app.pro +++ b/gpsbabel/gui/app.pro @@ -12,8 +12,13 @@ macx:DEFINES += HAVE_CONFIG_H ICON = images/appicon.icns QT += network \ - xml \ - webkit \ + xml \ + webkit + +greaterThan(QT_MAJOR_VERSION, 4) { + QT += widgets \ + webkitwidgets +} unix:DESTDIR = objects unix:MOC_DIR = objects diff --git a/gpsbabel/gui/main.cc b/gpsbabel/gui/main.cc index 0e50b6ed7..62393fbef 100644 --- a/gpsbabel/gui/main.cc +++ b/gpsbabel/gui/main.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "mainwindow.h" #include "gmapdlg.h" @@ -43,6 +44,15 @@ const char *pathSeparator = ":"; //------------------------------------------------------------------------ int main(int argc, char**argv) { +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) + // Qt 5.0 uses QString::fromUtf8 to convert from character pointers + // and QBytreArrays to QStrings while previous version of Qt used + // QString::fromAscii. QString::fromAscii used the codec set + // by QTextCode::setCodecForCStrings. + // This makes the conversion consistent between Qt4 and Qt5. + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); +#endif + QApplication *app; app = new QApplication(argc, argv); app->setWindowIcon(QIcon(":/images/appicon.png")); diff --git a/gpsbabel/gui/makelinuxdist.sh.in b/gpsbabel/gui/makelinuxdist.sh.in index bd1f87221..72707f7a0 100644 --- a/gpsbabel/gui/makelinuxdist.sh.in +++ b/gpsbabel/gui/makelinuxdist.sh.in @@ -20,7 +20,19 @@ done #cp `ldd objects/gpsbabelfe-bin | grep libaudio |awk '{print $3}'` $DISTDIR cp -r $QT_INSTALL_PLUGINS/imageformats $DISTDIR/plugins -cp -r $QT_INSTALL_PLUGINS/codecs $DISTDIR/plugins +if [ -e $QT_INSTALL_PLUGINS/codecs ] +then + cp -r $QT_INSTALL_PLUGINS/codecs $DISTDIR/plugins +else + echo "Warning: $QT_INSTALL_PLUGINS/codecs not found, perhaps this is normal for Qt5" +fi +if [ -e $QT_INSTALL_PLUGINS/platforms ] +then +# we need at least platforms/libqxcb.so + cp -r $QT_INSTALL_PLUGINS/platforms $DISTDIR/plugins +else + echo "Wanring: $QT_INSTALL_PLUGINS/platforms not found, this is normal for Qt4" +fi cp $QT_INSTALL_TRANSLATIONS/qt_*.qm $DISTDIR/translations/ # copy the compiled translations diff --git a/gpsbabel/gui/optionsdlg.cc b/gpsbabel/gui/optionsdlg.cc index b6564aaff..497945c54 100644 --- a/gpsbabel/gui/optionsdlg.cc +++ b/gpsbabel/gui/optionsdlg.cc @@ -94,7 +94,7 @@ OptionsDlg::OptionsDlg(QWidget*parent, const QString &fmtName, QListsetText(tr(options[k].getDescription().toAscii().data())); + checkBox->setText(options[k].getDescription()); horizontalLayout->addWidget(checkBox); checkBox->setChecked(options[k].getSelected()); //checkBox->setWhatsThis(options[k].getHtml()); -- 2.30.2